package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 商品业务状态码
 * 
 * @author 刘武
 *
 */
public enum ProductCode implements IBusinessCode {

	/**
	 * 商品属性名称不能重复
	 */
	OPTION_NAME_NOREPEATED(14001, "商品属性值名称不能重复"),

	/**
	 * 同一商圈内套餐名称不能重复
	 */
	PACKAGE_NAME_EXIST(14002, "同一商圈内套餐名称不能重复"),

	SKUID_NOTNULL(14004, "商品id不能为空"),

	/**
	 * 支付方式不包含积分，不能填写积分
	 */
	POINTS_NULL(14005, "支付方式不包含积分，不能填写积分"),

	SKU_NOT_EXSIT(14006, "商品不存在"),

	UNDERSTOCK(14007, "库存不足"),

	PRICE_NOTNULL(14009, "价格不能为空"),

	POINT_FORMAT(14010, "积分必须是正整数"),

	SORT_FORMAT(14011, "排序必须是正整数"),

	STOCK_FORMAT(14012, "库存必须是正整数"),

	MAXBUYNUM_FORMAT(14013, "限购必须是正整数"),

	PICTURE_NOTNULL(14014, "商品主图不能为空"),

	FILTER_TYPE_NOTNULL(14015, "筛选类型不能为空"),

	LIME_NOTNULL(14016, "有效时间不能为空"),

	LIME_LIMIT_FORMAT(14017, "有效开始时间不能大于有效结束时间"),

	ATTRIBUTE_NOTNULL(14018, "商品规格信息不能为空"),

	STOCK_CHANGE(14019, "商品出入库不能小于零"),

	SPU_STOCK_SKU_STOCK(14020, "商品总量和规格总量不一致"),
	/**
	 * 占用库存失败（需要重试，给C段的提示）
	 */
	LOCK_STOCK_FAILED(14021, "卖的太火爆，请稍后再试"),
	/**
	 * 占用库存失败（需要重试,给后台的提示）
	 */
	LOCK_STOCK_FAILED_BG(14022, "库存被其他用户占用了，请稍后再试"), 
	
	STOCK_NOT_ENOUGH(14023, "套餐内商品数量不能大于商品库存"), 
	
	SKU_NOT_NULL(14024, "套餐内商品不能为空"), 
	
	PACKAGE_STOCK_NOT_ENOUGH(14025, "套餐总量不能大于商品库存与商品数量比"),
	
	PACKAGE_ENDTIME_ERROR(14026, "套餐内商品结束时间不一致"),
	
	VALIDITY_PERIOD_ULTRA(14027, "商品有效期大于悦卡模板有效期"),

	BUSINESS_NOT_DIFFERENCE(14028,"请确认商品所在商圈！"),

	CONFIRM_THE_STATUS(14029, "请确认状态"),
	SPU_OVERDUE_STATUS(14030, "注意商品过期时间"),
	SETTLEMENT_PRICE_ERROR(14031, "特殊结算价不能大于商品价格小于0"),

	POINTS_MUST_GREATER_THAN_ZERO (14032, "积分商品积分不能小于0"),
	
	
	
	PRODUCT_TITLE_LENGTH_TOO_LOON (14033, "商品名称够长，请控制在30字符以内！"),
	
	BEGIN_TIME_IS_NOT_NULL (14034, "请选择开始时间"),
	
	CATEGORY_CANNOT_BE_EMPTY (14035, "商品类目不能为空"),
	
	TITLE_CANNOT_BE_EMPTY (14036, "商品类目不能为空"),
	
	PRICE_CANNOT_BE_NEGATIVE(14037, "价格必须是正数"),
	
	MAX_BUY_NUM_NOT_LESS_THAN_ZERO(14038, "限购必须是正整数"),

	SPU_PUBLISH_STATUS_ERROR(14039, "下架商品才能修改"),

	CAN_NOT_MODIFY_OWM_SPU(14040, "只能修改自己的商品"),
	
	PLEASE_CHOOSE_PICK_UP_TYPE(14041, "请选择提货方式"),

	SPU_OVERDUED(14042, "商品已过期"),
	
	UNOPENED_DELIVERY(14043, "商户尚未开启默认配送方式，请先开启配送方式再新建配送商品"),

	QUANTITY_CANNOT_BE_NEGATIVE(14044, "套餐子商品数量不能为负数"),
	GOODS_MUST_NOT_BE_GREATER_THAN_THE_COUPON(14045, "限购数大于模板限制数"),
    THE_GOODS_ARE_VALID_BEYOND_THE_COUPON_VALIDITY(14046, "商品有效期超出优惠券有效期"),
    END_TIME_CANNOT_BE_EARLIER_THAN_VIEW_END_TIME(14047, "核销时间不能早于倒计时结束时间！"),
    BEGIN_TIME_CANNOT_BE_EARLIER_THAN_BEGIN_TIME(14048, "核销时间不能早于倒计时开始时间！"),
	NO_COUPON_INFORMATION_FOUND(14049, "未找到商品券信息！"),
	COMMODITY_COUPON_PRODUCT_INFORMATION_CANNOT_BE_EMPTY(14050, "商品券商品信息不能为空！"),
	COLLECTION_RECORD_IS_EMPTY(14051, "领取记录为空！"),
	QUANTITY_CANNOT_EXCEED_HUNDRED(14052, "数量不能超过100！"),
	THE_TOTAL_ISSUANCE_IS_ONE_ONE_HUNDRED_THOUSAND(14053, "发放总量为1-100000！"),
	THE_REVIEW_STATUS_IS_NOT_UNDER_REVIEW_AND_CANNOT_BE_REVIEWED(14054, "审核状态不为审核中，不能进行审核"),
	ITEM_QUANTITY_IS_EMPTY(14055, "商品项数量为空"),
	THE_NUMBER_OF_REVIEWS_CANNOT_BE_GREATER_THAN_THE_NUMBER_OF_APPLICATIONS(14056, "审核数量不能大于申请数量"),
	TASK_TITLE_ERROR(14057, "任务名称不能重复"),
	SPU_MECOMMEND_MAX(14058, "推荐商品最多8个"),
	SPU_NOT_FREE(14059, "不是免费商品"),
	MEMBER_POINT_INCORRECT_DATA(14060,"%s"),

	ACTIVITY_NOT_EXIST(14061,"活动不存在"),
	ACTIVITY_CAN_NOT_DEL(14062,"活动不是草稿状态不能删除"),


	FORMAT_ERROR(14998,"%s格式错误"),
	CANNOT_BE_EMPTY (14999, "%s不能为空"),
	/**
	 * 状态码说明
	 */
	TODO(14000, "提示消息");

	private final Integer code;

	private final String message;

	private ProductCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code
	 *            代码
	 * @return
	 */
	public static ProductCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, ProductCode> CODE_MAP = Stream.of(ProductCode.values())
			.collect(Collectors.toMap(ProductCode::getCode, e -> e));

}
